/*
 * @Author: 詹真琦(legendryztachi@gmail.com)
 * @Date: 2022-04-25 11:28:20
 * @LastEditors: 詹真琦(legendryztachi@gmail.com)
 * @LastEditTime: 2022-04-25 11:28:21
 * @FilePath: \code\cwp-front\pc-collaboration\src\shim\append.js
 * @Description: Element.append
 */
// Source: https://github.com/jserz/js_piece/blob/master/DOM/Element/append()/append().md
(function (arr) {
    arr.forEach(function (item) {
        if (item.hasOwnProperty('append')) {
            return;
        }
        Object.defineProperty(item, 'append', {
            configurable: true,
            enumerable: true,
            writable: true,
            value: function append() {
                var argArr = Array.prototype.slice.call(arguments),
                    docFrag = document.createDocumentFragment();

                argArr.forEach(function (argItem) {
                    var isNode = argItem instanceof Node;
                    docFrag.appendChild(
                        isNode ? argItem : document.createTextNode(String(argItem))
                    );
                });

                this.appendChild(docFrag);
            },
        });
    });
})([Element.prototype, Document.prototype, DocumentFragment.prototype, HTMLDivElement.prototype]);
